﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Runtime.CompilerServices;

namespace SkypeTranslator.Utilities
{
	namespace Collection
	{
		public class DictionaryEventArgs<TKey, TItem> : EventArgs
		{
			private TKey _key;
			private TItem _item;
			public TKey Key
			{
				get
				{
					return this._key;
				}
			}
			public TItem Item
			{
				get
				{
					return this._item;
				}
			}
			public DictionaryEventArgs(TKey key, TItem item)
			{
				if (key == null)
					throw new ArgumentNullException("key");
				this._key = key;
				this._item = item;
			}
		}
		
		// public class ObservableDictionary<TKey, TItem> : IDictionary<TKey, TItem>, ICollection<KeyValuePair<TKey, TItem>>, IEnumerable<KeyValuePair<TKey, TItem>>, IEnumerable
		//{
		//    private readonly Dictionary<TKey, TItem> _dictionary;
		//    private event EventHandler<DictionaryEventArgs<TKey, TItem>> _itemAddedEvent
		//    {
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        add
		//        {
		//            this._itemAddedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemAddedEvent, value);
		//        }
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        remove
		//        {
		//            this._itemAddedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemAddedEvent, value);
		//        }
		//    }
		//    private event EventHandler<DictionaryEventArgs<TKey, TItem>> _itemChanging
		//    {
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        add
		//        {
		//            this._itemChanging = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemChanging, value);
		//        }
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        remove
		//        {
		//            this._itemChanging = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemChanging, value);
		//        }
		//    }
		//    private event EventHandler<DictionaryEventArgs<TKey, TItem>> _itemChanged
		//    {
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        add
		//        {
		//            this._itemChanged = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemChanged, value);
		//        }
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        remove
		//        {
		//            this._itemChanged = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemChanged, value);
		//        }
		//    }
		//    private event EventHandler<DictionaryEventArgs<TKey, TItem>> _itemRemovedEvent
		//    {
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        add
		//        {
		//            this._itemRemovedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemRemovedEvent, value);
		//        }
		//        [MethodImpl(MethodImplOptions.Synchronized)]
		//        remove
		//        {
		//            this._itemRemovedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemRemovedEvent, value);
		//        }
		//    }
		//    public event EventHandler<DictionaryEventArgs<TKey, TItem>> ItemAdded
		//    {
		//        add
		//        {
		//            this._itemAddedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemAddedEvent, value);
		//        }
		//        remove
		//        {
		//            this._itemAddedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemAddedEvent, value);
		//        }
		//    }
		//    public event EventHandler<DictionaryEventArgs<TKey, TItem>> ItemRemoved
		//    {
		//        add
		//        {
		//            this._itemRemovedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemRemovedEvent, value);
		//        }
		//        remove
		//        {
		//            this._itemRemovedEvent = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemRemovedEvent, value);
		//        }
		//    }
		//    public event EventHandler<DictionaryEventArgs<TKey, TItem>> ItemChanging
		//    {
		//        add
		//        {
		//            this._itemChanging = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemChanging, value);
		//        }
		//        remove
		//        {
		//            this._itemChanging = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemChanging, value);
		//        }
		//    }
		//    public event EventHandler<DictionaryEventArgs<TKey, TItem>> ItemChanged
		//    {
		//        add
		//        {
		//            this._itemChanged = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Combine(this._itemChanged, value);
		//        }
		//        remove
		//        {
		//            this._itemChanged = (EventHandler<DictionaryEventArgs<TKey, TItem>>)Delegate.Remove(this._itemChanged, value);
		//        }
		//    }
		//    public ICollection<TKey> Keys
		//    {
		//        get
		//        {
		//            return this._dictionary.Keys;
		//        }
		//    }
		//    public ICollection<TItem> Values
		//    {
		//        get
		//        {
		//            return this._dictionary.Values;
		//        }
		//    }
		//    public TItem this[TKey key]
		//    {
		//        get
		//        {
		//            return this._dictionary[key];
		//        }
		//        set
		//        {
		//            if (this._dictionary.ContainsKey(key))
		//            {
		//                DictionaryEventArgs<TKey, TItem> e = new DictionaryEventArgs<TKey, TItem>(key, this._dictionary[key]);
		//                this.OnItemChanging(e);
		//                this._dictionary[key] = value;
		//                e = new DictionaryEventArgs<TKey, TItem>(key, value);
		//                this.OnItemChanged(e);
		//                return;
		//            }
		//            this.Add(key, value);
		//        }
		//    }
		//    public int Count
		//    {
		//        get
		//        {
		//            return this._dictionary.Count;
		//        }
		//    }
		//    public bool IsReadOnly
		//    {
		//        get
		//        {
		//            return ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).IsReadOnly;
		//        }
		//    }
		//    public ObservableDictionary()
		//    {
		//        this._dictionary = new Dictionary<TKey, TItem>();
		//    }
		//    public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TItem>> other)
		//        : this()
		//    {
		//        foreach (KeyValuePair<TKey, TItem> current in other)
		//        {
		//            this.Add(current);
		//        }
		//    }
		//    public void Add(TKey key, TItem value)
		//    {
		//        this._dictionary.Add(key, value);
		//        this.OnItemAdded(new DictionaryEventArgs<TKey, TItem>(key, value));
		//    }
		//    public bool ContainsKey(TKey key)
		//    {
		//        return this._dictionary.ContainsKey(key);
		//    }
		//    public bool Remove(TKey key)
		//    {
		//        if (this._dictionary.ContainsKey(key))
		//        {
		//            DictionaryEventArgs<TKey, TItem> e = new DictionaryEventArgs<TKey, TItem>(key, this._dictionary[key]);
		//            this._dictionary.Remove(key);
		//            this.OnItemRemoved(e);
		//            return true;
		//        }
		//        return false;
		//    }
		//    public bool TryGetValue(TKey key, out TItem value)
		//    {
		//        return this._dictionary.TryGetValue(key, out value);
		//    }
		//    public void Add(KeyValuePair<TKey, TItem> item)
		//    {
		//        ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).Add(item);
		//        this.OnItemAdded(new DictionaryEventArgs<TKey, TItem>(item.Key, item.Value));
		//    }
		//    public void Clear()
		//    {
		//        if (this._itemRemovedEvent == null)
		//        {
		//            this._dictionary.Clear();
		//            return;
		//        }
		//        KeyValuePair<TKey, TItem>[] array = new KeyValuePair<TKey, TItem>[this._dictionary.Count];
		//        ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).CopyTo(array, 0);
		//        KeyValuePair<TKey, TItem>[] array2 = array;
		//        for (int i = 0; i < array2.Length; i++)
		//        {
		//            KeyValuePair<TKey, TItem> keyValuePair = array2[i];
		//            this.Remove(keyValuePair.Key);
		//        }
		//    }
		//    public bool Contains(KeyValuePair<TKey, TItem> item)
		//    {
		//        return ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).Contains(item);
		//    }
		//    public void CopyTo(KeyValuePair<TKey, TItem>[] array, int arrayIndex)
		//    {
		//        ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).CopyTo(array, arrayIndex);
		//    }
		//    public bool Remove(KeyValuePair<TKey, TItem> item)
		//    {
		//        bool flag = ((ICollection<KeyValuePair<TKey, TItem>>)this._dictionary).Remove(item);
		//        if (flag)
		//        {
		//            this.OnItemRemoved(new DictionaryEventArgs<TKey, TItem>(item.Key, item.Value));
		//        }
		//        return flag;
		//    }
		//    public IEnumerator<KeyValuePair<TKey, TItem>> GetEnumerator()
		//    {
		//        return ((IEnumerable<KeyValuePair<TKey, TItem>>)this._dictionary).GetEnumerator();
		//    }
		//    IEnumerator IEnumerable.GetEnumerator()
		//    {
		//        return this._dictionary.GetEnumerator();
		//    }
		//    protected virtual void OnItemAdded(DictionaryEventArgs<TKey, TItem> e)
		//    {
		//        EventsHelper.Fire(this._itemAddedEvent, this, e);
		//    }
		//    protected virtual void OnItemRemoved(DictionaryEventArgs<TKey, TItem> e)
		//    {
		//        EventsHelper.Fire(this._itemRemovedEvent, this, e);
		//    }
		//    protected virtual void OnItemChanging(DictionaryEventArgs<TKey, TItem> e)
		//    {
		//        EventsHelper.Fire(this._itemChanging, this, e);
		//    }
		//    protected virtual void OnItemChanged(DictionaryEventArgs<TKey, TItem> e)
		//    {
		//        EventsHelper.Fire(this._itemChanged, this, e);
		//    }
		//}
	}
}
